//
//  TabBarViewController.m
//  DanTang
//
//  Created by honeyrr on 2017/9/4.
//  Copyright © 2017年 honeyrr. All rights reserved.
//

#import "KATabBarViewController.h"
#import "KANavigationController.h"
#import "KABillViewController.h"
#import "KAStatisticsViewController.h"
#import "KAMeViewController.h"

@interface KATabBarViewController ()

@end

@implementation KATabBarViewController

+ (void)initialize
{
    NSDictionary *attrNormal = @{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:[UIColor grayColor]};
    NSDictionary *attrSelect = @{NSFontAttributeName:[UIFont systemFontOfSize:12],NSForegroundColorAttributeName:KANavTabColor};
    
    UITabBarItem *tbItem = [UITabBarItem appearance];
    [tbItem setTitleTextAttributes:attrNormal forState:UIControlStateNormal];
    [tbItem setTitleTextAttributes:attrSelect forState:UIControlStateSelected];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self allChildView];
}

- (void) allChildView
{
    [self addChildViewController:[KABillViewController new] tabBarItemTitle:@"账单" itemImgName:@"tabbar_bill_23x23" itemSelectedImgName:@"tabbar_bill_23x23_selected"];
    [self addChildViewController:[KAStatisticsViewController new] tabBarItemTitle:@"明细" itemImgName:@"tabbar_statistics_23x23" itemSelectedImgName:@"tabbar_statistics_23x23_selected"];
    [self addChildViewController:[KAMeViewController new] tabBarItemTitle:@"个人" itemImgName:@"tabbar_me_23x23" itemSelectedImgName:@"tabbar_me_23x23_selected"];
}

-(void)addChildViewController:(UIViewController *)viewController tabBarItemTitle:(NSString *)title itemImgName:(NSString *)itemImgName itemSelectedImgName:(NSString *)itemSelectedImgName{
    
    UITabBarItem * messageItem = [[UITabBarItem alloc]initWithTitle:title image:[UIImage imageNamed:itemImgName] selectedImage:[[UIImage imageNamed:itemSelectedImgName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    viewController.tabBarItem = messageItem;
    KANavigationController *navMessage = [[KANavigationController alloc]initWithRootViewController:viewController];
    
    viewController.navigationItem.title = title;
    [self addChildViewController:navMessage];
}


@end
